package com.zhaojiadi.singleton;

import java.util.Optional;

/**
 * @Description:懒汉模式线程安全
 */
public class Singleton_02 {
    private static Singleton_02 instance;

    private Singleton_02() {
    }

    public static synchronized Singleton_02 getInstance(){
        return Optional.ofNullable(instance).orElseGet(()->{
            instance=new Singleton_02();
            return instance;
        });
    }
}
